         
      <? 
      $articles=$this->db->query("select * from articles where father='$row->id' order by id"); 
      $rows=$articles->num_rows();
      ?>
     
<script type="text/javascript">

function check(){      
      if (
      		<?
      		$i=1;
          foreach ($articles->result() as $articles){ 
          
          if($i==1)
          echo "document.getElementById(\"checkme$articles->id\").checked";
          else
          echo " || document.getElementById(\"checkme$articles->id\").checked";

          $i=$i+1;
          }?>
          )
      {
      return true;	
      }else{
      alert("Выберите товар из таблицы");
      return false;	
      }
}

</script>

<? if ($this->agent->browser() == "Opera"){ ?>
<table border="0" cellspacing="0" cellpadding="0" class="dataTable">

<?}else{?>
<table border="0" cellspacing="0" cellpadding="0" class="dataTable" width="500">

<?}?>


      <form action="/store/add" method="post" name="buy" onSubmit="return check()">
      
          <thead> 
            <tr> 
            <th>Артикул</th> 
      
    <? 

        $captions = explode(";", $row->captions);
			  $ii=0;
			
				foreach ($captions as $caption) {
				$caption=trim($caption);
				$ii=$ii+1;
				
				    if($caption !='' && $caption !='~'){
					   echo "<th style=\"white-space:nowrap\">$caption</th>";
				    }
				}
    ?>        
        
          <th>Цена, грн</th>
          <th>&nbsp;</th>  
       </tr>
     </thead>
      
      <tbody> 

       <? $articles=$this->db->query("select * from articles where father='$row->id' order by article"); 
          $rows=$articles->num_rows();
      ?>         

  		<?	foreach ($articles->result() as $articles){ 
          $factors = explode(";", $articles->factors); ?>
          
          <? if ($articles->available == 1 && $articles->price != 0) {
              $font_color='black';
              }else{
              $font_color='gray';
              }
          ?>
          
           <? if ($articles->available == 1 && $articles->price != 0) {
           $hiden="1";
           ?>
            <tr class="even_row">
           <?}else{?>
            <tr class="hidden_row">
           <?}?> 
              <td valign="middle"><font color="<?=$font_color?>"><?=$articles->article?></font></td>
                <?$i=0?>
                <? foreach ($factors as $factor){ ?>
                <?$i=$i+1?>
				
					<? if($factor !='~'){?>
                  <td><font color="<?=$font_color?>"><?=$factor?></font></td>
				  	<?}?>
                <? } ?>
              <td valign="middle">
              <?
              if($articles->price !=0){
              
              global $dollar;
              $articles->price = $articles->price * $dollar;
              $articles->price = number_format($articles->price, 0, ',', ' ');
              
              $articles->old_price = $articles->old_price * $dollar;
              $articles->old_price = number_format($articles->old_price, 0, ',', ' ');
              ?>
              
              
              <? if($articles->old_price != 0){ ?>
              <font color="gray"><strike><?=$articles->old_price?></strike></font>
              <font color="#458B00"><strong><?=$articles->price?></strong></font>
              <?}else{?>
              
              	<font color="<?=$font_color?>"><strong><?=$articles->price?></strong></font>
              <?}?>
              
            
              <?}?>
              </td>   
              
              <? if ($articles->available == 1 && $articles->price != 0) {?>
              <td width="1%" ><input type="checkbox" name="id[<?=$articles->id?>]" id="checkme<?=$articles->id?>" <? if( $rows== 1) echo "checked" ?> ></td>
              <? }else{?>
              <td width="1">
                <input type="checkbox" id="checkme<?=$articles->id?>" disabled>
             </td >
              
              <?} ?>
            </tr>
         
        <? } ?>
        
        <tr>
        <td colspan="<?=$i+3?>" style="padding:0;margin:0">
         <div align="right" style="padding-top:0.5em;">
          <input type="submit" value=" Заказать " <? if ($hiden!=1) echo "disabled" ?>>
        </div>
        </td>
        </tr>
        
        

        </tbody>
       </form>
      </table>